﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ElasticSearchDemo.Controllers
{

    //NLog的Layout renderers参考官网: https://nlog-project.org/config/?tab=layout-renderers      
    public class LogTestController : Controller
    {

        private readonly ILogger<LogTestController> _logger;

        public LogTestController(ILogger<LogTestController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {

            _logger.LogInformation($"测试一下! : {DateTime.Now}");

            _logger.LogError($"测试一下错误! : {DateTime.Now}");

            _logger.LogWarning($"测试一下警告! : {DateTime.Now}");

            return View();
        }


        
        public IActionResult TestAjax()
        {
            _logger.LogInformation($"ajax请求测试 : {DateTime.Now}");

            return Ok(new { message="success" });
        }
    }
}
